package 力扣日常刷题.木22一月.第07天0115;

/**
 * @author 帅小伙
 * @date 2022/1/15
 * @description
 */
public class Demo02简单将标题首字母大写 {


    public String capitalizeTitle(String title) {
        title = title.toLowerCase();
        String[] s = title.split(" ");
        StringBuffer sb = new StringBuffer();
        for (String s1 : s) {
            if(s1.length() > 2){
                char c = s1.charAt(0);
                String res = s1.substring(0, 1).toUpperCase()+s1.substring(1,s1.length());
                sb.append(res+" ");
            }else{
                sb.append(s1+" ");
            }
        }

        return sb.toString().substring(0,sb.length()-1);
    }
}
